import 'package:gold/generated/json/base/json_convert_content.dart';
import 'package:gold/model/shop_model.dart';

ShopModel $ShopModelFromJson(Map<String, dynamic> json) {
  final ShopModel shopModel = ShopModel();
  final ShopUser? user = jsonConvert.convert<ShopUser>(json['user']);
  if (user != null) {
    shopModel.user = user;
  }
  final double? unpaidAmount = jsonConvert.convert<double>(json['unpaid_amount']);
  if (unpaidAmount != null) {
    shopModel.unpaidAmount = unpaidAmount;
  }
  final double? paidAmount = jsonConvert.convert<double>(json['paid_amount']);
  if (paidAmount != null) {
    shopModel.paidAmount = paidAmount;
  }
  final double? totalAmount = jsonConvert.convert<double>(json['total_amount']);
  if (totalAmount != null) {
    shopModel.totalAmount = totalAmount;
  }
  final int? salesAgent = jsonConvert.convert<int>(json['sales_agent']);
  if (salesAgent != null) {
    shopModel.salesAgent = salesAgent;
  }
  final int? visitorCount = jsonConvert.convert<int>(json['visitor_count']);
  if (visitorCount != null) {
    shopModel.visitorCount = visitorCount;
  }
  final int? orderCount = jsonConvert.convert<int>(json['order_count']);
  if (orderCount != null) {
    shopModel.orderCount = orderCount;
  }
  final int? unshippedCount = jsonConvert.convert<int>(json['unshipped_count']);
  if (unshippedCount != null) {
    shopModel.unshippedCount = unshippedCount;
  }
  final int? unpaidCount = jsonConvert.convert<int>(json['unpaid_count']);
  if (unpaidCount != null) {
    shopModel.unpaidCount = unpaidCount;
  }
  final int? unconfirmedCount = jsonConvert.convert<int>(json['unconfirmed_count']);
  if (unconfirmedCount != null) {
    shopModel.unconfirmedCount = unconfirmedCount;
  }
  return shopModel;
}

Map<String, dynamic> $ShopModelToJson(ShopModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['user'] = entity.user?.toJson();
  data['unpaid_amount'] = entity.unpaidAmount;
  data['paid_amount'] = entity.paidAmount;
  data['total_amount'] = entity.totalAmount;
  data['sales_agent'] = entity.salesAgent;
  data['visitor_count'] = entity.visitorCount;
  data['order_count'] = entity.orderCount;
  data['unshipped_count'] = entity.unshippedCount;
  data['unpaid_count'] = entity.unpaidCount;
  data['unconfirmed_count'] = entity.unconfirmedCount;
  return data;
}

extension ShopModelExtension on ShopModel {
  ShopModel copyWith({
    ShopUser? user,
    double? unpaidAmount,
    double? paidAmount,
    double? totalAmount,
    int? salesAgent,
    int? visitorCount,
    int? orderCount,
    int? unshippedCount,
    int? unpaidCount,
    int? unconfirmedCount,
  }) {
    return ShopModel()
      ..user = user ?? this.user
      ..unpaidAmount = unpaidAmount ?? this.unpaidAmount
      ..paidAmount = paidAmount ?? this.paidAmount
      ..totalAmount = totalAmount ?? this.totalAmount
      ..salesAgent = salesAgent ?? this.salesAgent
      ..visitorCount = visitorCount ?? this.visitorCount
      ..orderCount = orderCount ?? this.orderCount
      ..unshippedCount = unshippedCount ?? this.unshippedCount
      ..unpaidCount = unpaidCount ?? this.unpaidCount
      ..unconfirmedCount = unconfirmedCount ?? this.unconfirmedCount;
  }
}

ShopUser $ShopUserFromJson(Map<String, dynamic> json) {
  final ShopUser shopUser = ShopUser();
  final int? uid = jsonConvert.convert<int>(json['uid']);
  if (uid != null) {
    shopUser.uid = uid;
  }
  final String? avatar = jsonConvert.convert<String>(json['avatar']);
  if (avatar != null) {
    shopUser.avatar = avatar;
  }
  final String? nickname = jsonConvert.convert<String>(json['nickname']);
  if (nickname != null) {
    shopUser.nickname = nickname;
  }
  return shopUser;
}

Map<String, dynamic> $ShopUserToJson(ShopUser entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['uid'] = entity.uid;
  data['avatar'] = entity.avatar;
  data['nickname'] = entity.nickname;
  return data;
}

extension ShopUserExtension on ShopUser {
  ShopUser copyWith({
    int? uid,
    String? avatar,
    String? nickname,
  }) {
    return ShopUser()
      ..uid = uid ?? this.uid
      ..avatar = avatar ?? this.avatar
      ..nickname = nickname ?? this.nickname;
  }
}